package com.merelyb.data.service.service.service.affpay;

import com.merelyb.data.service.common.MultiDataSourceContextHolder;
import com.merelyb.data.service.service.mybatis.bean.affpay.AffpayPaymentFrequency;
import com.merelyb.data.service.service.mybatis.dao.affpay.AffpayPaymentFrequencyDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by LiM on 2017/12/16.
 */
@Service
public class AffpayPaymentFrequencyService {
    @Autowired
    AffpayPaymentFrequencyDao affpayPaymentFrequencyDao;

    /**
     * 查询数据
     *
     * @param affpayPaymentFrequency
     * @return
     * @throws Exception
     */
    public List<AffpayPaymentFrequency> queryAllList(AffpayPaymentFrequency affpayPaymentFrequency) throws Exception {
        return affpayPaymentFrequencyDao.queryAllList(affpayPaymentFrequency, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 分页查询数据
     *
     * @param affpayPaymentFrequency
     * @return
     */
    public List<AffpayPaymentFrequency> queryListByLimit(AffpayPaymentFrequency affpayPaymentFrequency) {
        return affpayPaymentFrequencyDao.queryListByLimit(affpayPaymentFrequency, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 新增单条数据
     *
     * @param affpayPaymentFrequency
     * @throws Exception
     */
    public void addData(AffpayPaymentFrequency affpayPaymentFrequency) throws Exception {
        affpayPaymentFrequencyDao.addData(affpayPaymentFrequency, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 批量新增数据
     *
     * @param affpayPaymethodList
     * @throws Exception
     */
    public void addData(List<AffpayPaymentFrequency> affpayPaymethodList) throws Exception {
        affpayPaymentFrequencyDao.addData(affpayPaymethodList, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 更新数据
     *
     * @param affpayPaymentFrequency
     * @throws Exception
     */
    public void updateData(AffpayPaymentFrequency affpayPaymentFrequency) throws Exception {
        affpayPaymentFrequencyDao.updateData(affpayPaymentFrequency, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 更新数据状态
     *
     * @param affpayPaymentFrequency
     * @throws Exception
     */
    public void deleteData(AffpayPaymentFrequency affpayPaymentFrequency) throws Exception {
        affpayPaymentFrequencyDao.deleteData(affpayPaymentFrequency, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 统计数量
     *
     * @param affpayPaymentFrequency
     * @return
     */
    public int getCount(AffpayPaymentFrequency affpayPaymentFrequency) {
        return affpayPaymentFrequencyDao.getCount(affpayPaymentFrequency, MultiDataSourceContextHolder.DATA_AFFPAY);
    }

    /**
     * 获取所有周期类型
     * @param affpayPaymentFrequency
     * @return
     * @throws Exception
     */
    public List<String> getAffpayPaymentFreType(AffpayPaymentFrequency affpayPaymentFrequency) throws Exception {
        return affpayPaymentFrequencyDao.getAllPayCommissionType(affpayPaymentFrequency, MultiDataSourceContextHolder.DATA_AFFPAY);
    }
}
